/*
生成一只新乌龟，我需要使用服务/turtle1/spwan

//快速验证一个话题发布，这里验证控制乌龟运动的话题
rostopic pub -r 10 /turtle2/cmd_vel geometry_msgs/Twist 
"linear:
  x: 0.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 1.0"     
*/

#include "ros/ros.h"
#include "turtlesim/Spawn.h"

int main(int argc, char *argv[])
{
    //初始化节点等操作
    setlocale(LC_ALL, "");
    ros::init(argc, argv, "new_turtle");
    ros::NodeHandle nh;

    //创建一个客户端，发起服务，生成一只乌龟
    ros::ServiceClient client = nh.serviceClient<turtlesim::Spawn>("/spawn");
    //等待服务器启动
    client.waitForExistence();
    turtlesim::Spawn request;
    request.request.x = 1;
    request.request.y = 1;
    request.request.theta = 1.57;
    request.request.name = "turtle2";
    bool ret = client.call(request);
    if (ret)
    {
        ROS_INFO("生成新乌龟成功！");
    }
    else
    {
        ROS_INFO("生成新乌龟失败!");
    }
    ros::spin();
    return 0;
}
